#include "../Http.hpp"

#include <unistd.h>
#include <assert.h>

int main()
{
    Socket clisock;
    clisock.CreateClinet("127.0.0.1",9090);
    // 请求头指定正文有100个字节，但实际上没有。连续发送多条请求，看服务器是否能够正确拼凑出一条完整的请求
    std::string req = "GET /hello HTTP/1.1\r\nConnection: keep-alive\r\nContent-Length: 100\r\n\r\n你好";
    while(true)
    {
        assert(clisock.Send(req.c_str(),req.size()) != -1);
        assert(clisock.Send(req.c_str(),req.size()) != -1);
        assert(clisock.Send(req.c_str(),req.size()) != -1);
        char buffer[1024] = {0};
        clisock.Recv(buffer,sizeof(buffer) - 1);
        DEBUG_LOG("[%s]",buffer);
        sleep(3);
    }
    clisock.Close();
    return 0;
}